/*
 *  Triangle.h
 *  project4
 *
 *  Created by Maria Piao on 09-11-18.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef _TRIANGLE_H
#define _TRIANGLE_H

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include "Point.h"

using namespace std;

class Triangle {
public:
        Triangle(Point* point1, Point* point2, Point* point3);
        ~Triangle();
        double getArea();                           //Returns Area of the triangle (Uses Heron's Formula). Area used in triangulator
        bool isExit();                              //Variables that show the triangles status
        bool isEntrance();
		bool contains(Point* point);                //Checks if a point is inside the triangle
        Point* getPoint1();                         //returns corresponding points in the triangle
        Point* getPoint2();
        Point* getPoint3();

	//Neighbour methods: getNeighbourBetween12 returns the neighbour that shares point1 and point2, etc
        Triangle* getNeighbourBetween12();
        Triangle* getNeighbourBetween23();
        Triangle* getNeighbourBetween31();

        void setNeighbourBetween12(Triangle* t);
        void setNeighbourBetween23(Triangle* t);
        void setNeighbourBetween31(Triangle* t);

        bool assignNeighbour(Triangle* t);
        void print();                               //prints triangle

		//Jason's new functions
		enum DelaunayStatus {
             Yes, NotSure, No
		};
		DelaunayStatus getDelaunayStatus (void);
		void setDelaunayStatus (DelaunayStatus newStatus);
	void setPoint1(Point *p);
	void setPoint2(Point *p);
	void setPoint3(Point *p);

protected:
        Point* point1;
        Point* point2;
        Point* point3;
        Triangle* neighbour12;
        Triangle* neighbour23;
        Triangle* neighbour31;

        bool ifTwoOutOfThree(Point* point1, Point* point2, Point* a, Point* b, Point* c);

        bool ifOneOutOfTwo(Point* point1, Point* a, Point* b);

		// Jason's new functions
		DelaunayStatus delaunayStatus;

public:
        bool exit, entrance;
};


#endif



